package cn.xinfei.xdecision.common.model.datax.enums;

import cn.xinfei.xdecision.common.model.datax.exception.XDecisionDataException;
import cn.xinfei.xdecision.common.model.datax.exception.XDecisionDataExceptionType;

import java.util.Arrays;

public enum MigrateEnum {
    VAR_PARAM,
    JAVA_THIRDPARTY,
    JAVA_BIZ,
    JAVA_BASIC,
    JAVA_COMBO,
    PYTHON_THIRDPARTY,
    PYTHON_THIRDPARTY_CACHE,
    PYTHON_BIZ,
    PYTHON_MODEL,
    PYTHON_MODEL_CACHE,
    PYTHON_BASIC;

    public static MigrateEnum fromName(String name) {
        return Arrays.stream(MigrateEnum.values())
                .filter(item -> item.name().equals(name))
                .findFirst()
                .orElseThrow(() ->
                        new XDecisionDataException(XDecisionDataExceptionType.COMMON_SERVER_ERROR,
                                "no such migrate type for" + name));
    }
}
